<template>
	<view class="main animated fadeIn faster">
		<TitleBarVue :title="title"/>
		<view class="version">
			<view class="icon">
				<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/xiaodazudui.png" style="width: 374rpx;height: 129rpx;"></image>
			</view>
			<view class="text">小嗒组队</view>
			<view class="VersionNumber" v-if="version_number">Version {{version_number}}</view>
		</view>
		<view class="list" style="margin-top: 40rpx;">
			<view class="item" @click="appVersion">
				<text>检查更新</text>
				<view class="icon">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%202457.png"></image>
				</view>
			</view>
			<view class="item" @click="open">
				<text>帮助中心</text>
				<view class="icon">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%202457.png"></image>
				</view>
			</view>
			<view class="item" @click="gotoFeedBack">
				<text>意见反馈</text>
				<view class="icon">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%202457.png"></image>
				</view>
			</view>
			<view class="item" @click="GoCheckIt">
				<text>小嗒简介</text>
				<view class="icon">
					<image src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/app/%E7%BB%84%202457.png"></image>
				</view>
			</view>
		</view>
		<view class="bottom">
			<view class="agreement">
				<view class="item" @click="gotoUserAgreement">用户协议|</view>
				<view class="item" @click="gotoPrivacyPolicy">隐私政策|</view>
				<view class="item" @click="gotoPersonalInfoList">个人信息收集清单</view>
			</view>
			<view class="NetworkSignal">
				<view class="item">鄂ICP备2022017141号-1</view>
				<view class="item">鄂公网安备42011102005657号</view>
			</view>
		</view>
		
		<uni-popup ref="editPswPopup" background-color="#fff" border-radius="8px 8px 8px 8px">
			<view class="popup-content editPsw" :class="{ 'popup-height': type === 'left' || type === 'right' }" style="height: 250rpx;">
				<view class="text-center font32 font-bold mt-3" >帮助中心</view>
				<view class="desc text-center mt-5 mx-2">如果您有什么问题或者困惑可以联系我们：</view>
				<view class="mt-1 text-center mx-2">电子邮箱：17671638871@163.com</view>
				<!-- <view class="btn d-flex position-absolute" style="width: 100%; bottom: 0;">
					<view class="confirm text-center font28" style="width: 100%;  line-height: 80rpx; height: 80rpx; border-top: 1px solid rgba(204, 204, 204, .3);" @click="ColsePawePopup">确认</view>
				</view> -->
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import TitleBarVue from '../../components/TitleBar.vue';
	import store from '@/store/index.js';
	import { userApi } from '../../http/userApi';
	import appUpdate from '@/js_sdk/wczd-app-update/js_sdk/app-update.js'
	export default {
		data() {
			return {
				title: '关于小嗒组队',
				version_number: "",
				isPopupVisible: false, // 控制弹窗显示隐藏
				email: 'service@example.com' // 帮助中心邮箱
			}
		},
		components: {TitleBarVue},
		methods: {
			open(type){
				this.type = type
				this.$refs.editPswPopup.open(type)
			},
			ColsePawePopup() {
				this.$refs.editPswPopup.close()
			},
			appVersion(){
				// #ifdef APP
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					userApi.version().then((res)=>{
						if (widgetInfo.version != res.versionCode) {
							if (uni.getSystemInfoSync().platform === 'android') {
								appUpdate({
									"platform":"android",
									"updateContent":"新版本已经准备好了，请更新...",
									"downUrl":res.apkUrl,
									"version":res.versionCode,
									"force":res.isForce,
									"mainColor":"FF5B78",
								})
							}
						}else{
							console.log('app最新版本')
						}
					})
				});
				// #endif
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			gotoUserAgreement() {
				uni.navigateTo({
					// url: '/pagesMain/UserAgreement/UserAgreement',
					url:'/pagesMain/privacy/privacy?type=2'
				})
			},
			gotoPrivacyPolicy() {
				uni.navigateTo({
					// url: '/pagesMain/PrivacyPolicy/PrivacyPolicy',
					url:'/pagesMain/privacy/privacy?type=1'
				})
			},
			gotoPersonalInfoList() {
				uni.navigateTo({
					url: '/pagesMain/PersonalInformationList/PersonalInformationList'
				})
			},
			gotoFeedBack() {
				uni.navigateTo({
					url: '/pagesMain/Feedback/Feedback'
				})
			},
			GoCheckIt() {
				uni.navigateTo({
					url: '/pagesApp/App-introduce/App-introduce'
				})
			}
		},
		onLoad() {
			const systemInfo = uni.getSystemInfoSync();
			
			// #ifdef MP-WEIXIN
				const accountInfo = wx.getAccountInfoSync();
				this.version_number = accountInfo.miniProgram.version
			// #endif
			
			// #ifdef APP
				this.version_number = systemInfo.appWgtVersion;
			// #endif
			
			// #ifdef H5
				const uniAppVersion = systemInfo.appVersion;
				this.version_number = uniAppVersion
			// #endif
			
			console.log(this.version_number);
		}
	}
</script>

<style scoped lang="scss">
.main {
	background: #fff;
	overflow: hidden;
	.content {
		width: 100%;
		background-color: #fff !important;
	}
	.version {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 200rpx;
		.icon {
			margin: 30rpx 0 10rpx;
			image {
				width: 300rpx;
				height: 120rpx;
			}
		}
		.text {
			font-size: 30rpx;
			margin-bottom: 10rpx;
		}
		.VersionNumber {
			font-size: 26rpx;
		}
	}
	.list {
		margin-top: 20rpx;
		padding: 0 20rpx 0 40rpx;
		.item {
			display: flex;
			justify-content: space-between;
			padding: 30rpx 0;
			border-bottom: 1px solid rgba(204, 204, 204, .4);
			font-size: 28rpx;
			text {
				color: #555;
			}
			.icon {
				display: flex;
				justify-content: center;
				align-items: center;
				image {
					margin-right: 30rpx;
					width: 10rpx;
					height: 20rpx;
					transform: rotate(180deg);
				}
			}
		}
	}
	.bottom {
		position: absolute;
		width: 100%;
		bottom: 300rpx;
		.agreement {
			text-align: center;
			margin-bottom: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			.item {
				color: #71abe9;
				font-size: 28rpx;
			}
		}
		.NetworkSignal {
			.item {
				text-align: center;
				font-size: 22rpx;
				color: #797979;
			}
		}
	}
}
.popup_box {
		width: 100%;
		height: 100vh;
		background-color: rgba(0, 0, 0, .4);
		position: fixed;
		top: 0;
		left: 0;
		.PswPopup {
			width: 450rpx;
			height: 500rpx;
			border-radius: 30rpx;
			background-color: #fff;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50% ,-50%);
			padding: 0 50rpx;
			overflow: hidden;
			.title {
				width: 100%;
				font-size: 36rpx;
				display: flex;
				justify-content: center;
				padding: 30rpx 0;
			}
			
			.btns {
				height: 60rpx;
				margin-top: 60rpx;
				float: right;
				button {
					padding: 8rpx 40rpx;
					border-radius: 15rpx;
					margin: 0 30rpx;
				}
			}
		}
	}
.title {
	display: flex;
	align-items: center;
	height: 80rpx;
	padding-right: 47rpx;
	text {
		flex: 1;
		margin-right: 50rpx;
		font-size: 32rpx;
		text-align: center;
	}
}
.pt-300 {
	padding-top: 300rpx;
}
</style>
